<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>$http服务获取后台数据</title>
		<script src="../org/angular.min.js"></script>
		<script src="../org/jquery.min.js" ></script>
	</head>
	<body>
		<div ng-app="hd" ng-controller="ctrl">
			<table width="600" border="1px">
				<tr>
					<td>名称</td>
					<td>链接</td>
				</tr>
				<tr ng-repeat='v in data'>
					<td>{{v.name}}</td>
					<td>{{v.url}}</td>
				</tr>
			</table>
		</div>
		<script>
			var m = angular.module('hd',[]);
			
			m.controller('ctrl',['$scope','$http',function($scope,$http){
//				$http({
//					method:'get',
//					url:'$httpPhp.php',
//                  cache:true,   //将请求服务缓存起来，减少请求次数
//				}).then(function(response){
//					$scope.data = response.data;
//					console.log(response); //成功时执行
//				},function(response){
//					console.log(response); //失败时执行
//				});

//              简写方式
//              $http.get('$httpPhp.php',{cache:true}).then(function(response){
//					$scope.data = response.data;
//					console.log(response); //成功时执行
//				},function(response){
//					console.log(response); //失败时执行
//				});
                $http.post('$httpPhp.php',{id:1}).then(function(response){  //id请求参数
					$scope.data = response.data;
					console.log(response); //成功时执行
				},function(response){
					console.log(response); //失败时执行
				});
			}]);
		</script>
	</body>
</html>

